jQuery(document).ready(function(){
										$('.up').hover(function() {
	  $(this).animate({ opacity : 1 }, 100);
	}, function() {
	  $(this).animate({ opacity : 0.6 }, 100);
	})
	
	$(".up").click(function(event){
	  event.preventDefault();
		$("html, body").animate({ scrollTop: 0 }, 600);
	});
	

	$('.socialmedia .social li').hover(function() {
		$(this).find('a').clone().addClass('hover').appendTo($(this));
	  $(this).find('a:first-child').stop().animate({ marginTop: -25 }, 150);
	}, function() {
	  $(this).find('a:first-child').stop().animate({ marginTop: 0, opacity: 0.99 }, 150);
	  setTimeout(function() { $(this).find('a.hover').remove(); }, 150);
	});
	
	
	
	/*---------------------------------------------- 
				Portfolio Hover Effect 
	------------------------------------------------*/	

		function portfolio_hover(){
			//Set the height according to the portfolio image
			height = jQuery('.portfolio-item .post-image img').height();
			
			jQuery('.portfolio-style-1 .portfolio-item .post-info').css('top',-height);
			jQuery('.portfolio-style-1 .portfolio-item').hover(function(){
				jQuery(".post-info", this).stop().animate({'top':'0px'},{queue:false,duration:300});
			}, function() {
				jQuery(".post-info", this).stop().animate({'top':-height},{queue:false,duration:800});
			});

			jQuery('.portfolio-item .portfolio-icons').css('top',height);
			jQuery('.portfolio-item').hover(function(){
				jQuery(".portfolio-icons", this).stop().animate({'top':height - '40'+'px'},{queue:false,duration:300});
			}, function() {
				jQuery(".portfolio-icons", this).stop().animate({'top':height},{queue:false,duration:300});
			});
			
			// For each image
			jQuery('.portfolio-item .post-image').each(function() {
				// If the image has a class of 'post-image' and the children element doesn't have a 'mask-overlay' class
				if(jQuery(this).attr('class') == 'post-image' && jQuery(this).children().attr('class') !== 'mask-overlay') {
					jQuery(this).css('cursor', 'default')
					jQuery(this).prepend('<span class="mask-overlay"></span>');
				}
			});
			
			jQuery('.portfolio-item').each(function(){
				jQuery(this).find('.mask-overlay').css('opacity','0');
				jQuery(this).hover(function(){
					jQuery(this).find('.mask-overlay').stop().animate({'opacity': 0.3});	
				}, function(){
					jQuery(this).find('.mask-overlay').stop().animate({'opacity': 0});
				});
			});	
			return false;
		}
		
		portfolio_hover();

	/*---------------------------------------------- 
				Image Hover Effect 
	------------------------------------------------*/	
		var image_hover = jQuery('a.image-icon-zoom, a.image-icon-link, a.image-icon-play, a.image-no-link');
		jQuery(image_hover).each(function(){
			if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {} else {
				if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 9) {
					jQuery(this).hover(function(){
						jQuery(this).find('.image-overlay').css("visibility", "visible");
					},function(){
						jQuery(this).find('.image-overlay').css("visibility", "hidden");
					}).children('img').before('<span class="mask-overlay"></span>').after('<span class="image-overlay"></span>');
				} else{
				jQuery(this).hover(function(){
						jQuery(this).find('.image-overlay').stop().animate({
							opacity: '1'
						},"fast");
					},function(){
						jQuery(this).find('.image-overlay').stop().animate({
							opacity: '0'
						},"fast");
					}).children('img').before('<span class="mask-overlay"></span>').after(jQuery('<span class="image-overlay"></span>').css({opacity: '0',visibility:'visible'}));
				}
				
				jQuery(this).find('.mask-overlay').css('opacity','0');
				jQuery(this).hover(function(){
					jQuery(this).find('.mask-overlay').stop().animate({'opacity': 0.3});	
				}, function(){
					jQuery(this).find('.mask-overlay').stop().animate({'opacity': 0});
				});
			}
		});
		jQuery('.image-no-link').click(function(){
			return false;
		});

		/*---------------------------------------------- 
				prettyPhoto Plugin Settings 
	------------------------------------------------*/	
		function prettyPhoto(){
			if (jQuery('a.image-icon-zoom').attr('data-rel') == undefined || jQuery('a.image-icon-zoom').attr('data-rel') == '') {
				jQuery("a.image-icon-zoom").attr("data-rel","prettyPhoto");}
				
			if (jQuery('a.image-icon-play').attr('data-rel') == undefined || jQuery('a.image-icon-play').attr('data-rel') == '') {
				jQuery("a.image-icon-play").attr("data-rel","prettyPhoto");}
				
			jQuery(".portfolio-container > .portfolio-item .post-image span").children("a.image-hover").attr("data-rel","prettyPhoto[gal]");
			
			jQuery(".portfolio-container > .portfolio-item .post-image span").children("a.video-hover").attr("data-rel","prettyPhoto[gal]");
			
			jQuery(".portfolio-container > .portfolio-item .post-image span").children("a.link-hover").removeAttr("data-rel");
									
			jQuery("a.image-no-link").removeAttr("data-rel");
			
			jQuery("a[data-rel^='prettyPhoto']").prettyPhoto({
				animation_speed: 'fast', // fast/slow/normal 
				opacity: 0.70, // Value between 0 and 1 
				show_title: true, // true/false 
				allow_resize: true, // Resize the photos bigger than viewport. true/false 
				default_width: 500,
				default_height: 344,
				theme: 'pp_default', // light_rounded / dark_rounded / light_square / dark_square / facebook 
				overlay_gallery: false, // If set to true, a gallery will overlay the fullscreen image on mouse over 
				deeplinking: false, // Allow prettyPhoto to update the url to enable deeplinking. 
				social_tools: false
			})
			return false;
		}
		
		prettyPhoto();
		
		/*---------------------------------------------- 
				     Filter
	------------------------------------------------*/
	// onclick reinitialise the isotope script
	$('.filter li a').click(function(){
		
		$('.filter li a').removeClass('active');
		$(this).addClass('active');
		
		var selector = $(this).attr('data-option-value');
		$container.isotope({ filter: selector });
		
		return(false);
	});
	
		/*---------------------------------------------- 
				   Isotope   (masonry)
	------------------------------------------------*/
		var $container = $('#masonry');
	$container.imagesLoaded( function(){
		$container.isotope({
			itemSelector : '.masonry_item'
		});	
	});
//INITIALIZES TWITTER FEED PLUGIN

	$('.twitter-feed').tweet({
		username: 'umrahticket',  //just enter your twitter username
		join_text: 'auto',
		avatar_size: null,
		count: 2, //number of tweets showing
		auto_join_text_default: '',
		loading_text: 'loading latest tweets...' //text displayed while loading tweets
	});
	/*---------------------------------------------- 
				Scroll 
	------------------------------------------------*/
$('#menu a, #logo, .scrol').click(function() {
	var elementClicked = $(this).attr("href");
	var destination = $(elementClicked).offset().top;
	$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-0}, 1000 );		   
	return false;
});	
		
});

	
var current_nav = 'home';

scroll_function = function(){
	
	$(".scrol-page,").each(function(index) {
		var h = $(this).offset().top;
		var y = $(window).scrollTop();
					
		if(y + 360 >= h && y < h + $(this).height() && $(this).attr('id') != current_nav) {
			
			current_nav = $(this).attr('id');
			
			$('#menu a').removeClass('current');
			$('.nav_' + current_nav).addClass('current').show("fast");	
				
		}
	});	
}
$(window).scroll(function(){
		scroll_function();
});	

	/*---------------------------------------------- 
				Navigation 
	------------------------------------------------*/
	$('#menu a').click( function () {
	$('#menu a').removeClass("active");
	$(this).addClass("active");
	}); 

	$('#logo').click( function () {
	$('#menu a').removeClass("active");
	}); 
	

	/*---------------------------------------------- 
				Sliding graph
	------------------------------------------------*/
jQuery(document).ready(function($){
	function isScrolledIntoView(id)
	{
		var elem = "#" + id;
		var docViewTop = $(window).scrollTop();
		var docViewBottom = docViewTop + $(window).height();
	
		if ($(elem).length > 0){
			var elemTop = $(elem).offset().top;
			var elemBottom = elemTop + $(elem).height();
		}

		return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
		  && (elemBottom <= docViewBottom) &&  (elemTop >= docViewTop) );
	}

	
	
	function sliding_horizontal_graph(id, speed){
		//alert(id);
		$("#" + id + " li span").each(function(i){
			var j = i + 1; 										  
			var cur_li = $("#" + id + " li:nth-child(" + j + ") span");
			var w = cur_li.attr("title");
			cur_li.animate({width: w + "%"}, speed);
		})
	}
	
	function graph_init(id, speed){
		$(window).scroll(function(){
			if (isScrolledIntoView(id)){
				sliding_horizontal_graph(id, speed);
			}
			else{
				//$("#" + id + " li span").css("width", "0");
			}
		})
		
		if (isScrolledIntoView(id)){
			sliding_horizontal_graph(id, speed);
		}
	}
	
	graph_init("services-graph", 1000);
	

});

	/*---------------------------------------------- 
				Form Validaton Javascript 
	------------------------------------------------*/

$(document).ready(function() {
	$('form#contact_form').submit(function() {
		$('form#contact_form .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
            	var labelText = $(this).prev('label').text();
            	$(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');
            	$(this).addClass('inputError');
            	hasError = true;
            } else if($(this).hasClass('email')) {
            	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            	if(!emailReg.test(jQuery.trim($(this).val()))) {
            		var labelText = $(this).prev('label').text();
            		$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
            		$(this).addClass('inputError');
            		hasError = true;
            	}
            }
		});
		if(!hasError) {
			$('form#contact_form input.submit').fadeOut('normal', function() {
				$(this).parent().append('');
			});
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contact_form').slideUp("fast", function() {
					$(this).before('<p class="success"><strong>Thanks!</strong> Your email was successfully sent. We will contact you as soon as possible.</p>');
				});
			});
		}

		return false;

	});
});
